package com.sghd.candy.module.shop.manager;

import com.sghd.common.ramcache.anno.Inject;
import com.sghd.common.ramcache.service.EntityCacheService;
import org.springframework.stereotype.Component;

import java.util.Comparator;
import java.util.List;

/**
 * @author Allen
 * @date 2019/01/09
 */
@Component
public class ShopManager {
    @Inject
    private EntityCacheService<String, ShopConfig> shopCache;
    public ShopConfig load(String shopId) {
        return shopCache.load(shopId);
    }
    public List<ShopConfig> list() {
        return shopCache.getFinder().find(
                finder -> {
                    if (!finder.getValid()) {
                        return true;
                    }
                    return false;
                },

                Comparator.comparing(ShopConfig::getId));
    }
}
